package main

import (
	"fmt"
	"github.com/spf13/cobra"
	"github.com/spf13/pflag"
	"linux_command/command"
)

func main() {
	command.RootCmd.SetHelpFunc(func(cmd *cobra.Command, args []string) {
		fmt.Println("Usage:")
		fmt.Printf("  %s [command]\n\n", cmd.Name())
		fmt.Println("Available Commands:")
		for _, c := range cmd.Commands() {
			if c.Hidden {
				continue
			}
			fmt.Printf("  %-20s %s\n", c.Name(), c.Short)
		}
		fmt.Println("\nFlags:")
		cmd.Flags().VisitAll(func(f *pflag.Flag) {
			fmt.Printf("  --%s\t%s\n", f.Name, f.Usage)
			//fmt.Printf("  --%s\t%s\n", cmd.Name(), cmd.Long)
		})
	})
	command.Execute()
}
